--- 战斗主类
---
--- @class Fight
Fight = ClientFight.CreateClass("Fight", ClientFight.AbstractFight)
local Fight = Fight

--- @public
--- @return Fight
function Fight:ctor(team, site)
    --当前战斗帧数*/
    --- @type number
    self.frame = 0;
    --战斗持续最大帧数*/
    --- @type number
    self.maxFrame = 0;
    --结束*/
    --- @type number
    self.finish = 0;
    --随机种子*/
    self.randomSeed = tostring(os.time()):reverse():sub(1, 7);
    --随机*/
    -- private transient Random random;
    --停顿次数*/
    --- @type number
    self.pause = 0;

    --双方队伍*/
    --- @type table<number,FightTeam>
    self.teams = {};

    --[[
    * 战斗中计算AI单位
    * 战斗跑逻辑帧的时候先从 teams addAll到这里 然后遍历计算ai
    * */]]
    --- @type table<number,Fighter>
    --self.aiFighters = {};

    --战斗中正在释放聚光灯效果的技能*/
    --- @type table<number,FightUsingSkill>
    self.frozenSkills = {};
    --战斗中正在释放的技能*/
    --- @type table<number,FightUsingSkill>
    self.skills = {};
    --战斗中结算技能*/
    --- @type table<number,FightUsingSkill>
    self.actionSkills = {};

    --[[
    * 战斗延时事件
    * <事件作用帧数, <事件>>
    */]]
    --- @type table<number,table<number,IFightDelayedEvent>>
    self.events = {}
    --[[
    * 战斗触发事件
    * <事件触发时机, <事件触发角色, <事件触发ID, 事件>>>
    */]]
    --- @type table<number,table<number,table<numberIFightDelayedEvent>>>

    self.eventListeners = {};
    --ID生成*/AtomicInteger
    self.ids = 1;
    --BUFFID生成*/AtomicInteger
    self.buffIds = 1;
    --SKILLID生成*/AtomicInteger
    self.skillIds = 1;
    --游戏中执行的指令*/
    --private transient ArrayList<ICmd> cmds = new ArrayList<>();
    --游戏中执行的行为*/
    --- @type table<number,table<number,table>>
    self.actions = {};

    self.frameInfo = {};

    -- 命中率等级压制系数 */
    --- @type number
    self.hitrate_suppress = 0;
    -- 等级压制系数 */
    --- @type number
    self.damage_suppress = 0;
    -- 战斗服 战报的存储策略 {@link ReportSaveTypeEnum}*/
    --private int reportSaveTypeEnum = ReportSaveTypeEnum.TYPE_DEFAULT.getId();
    --- @type  table<number,table<number,table<number,number>>

    self.fightSites = { { {} } };
    self.fightSitesPuppet = { { {} } };

end
--[[
* 加入黑频技能
*/]]

function Fight:random(value)
    local nextInt = math.random(value);
    return math.floor(nextInt);
end

function Fight:getRandSeed()
    return self.self.randomSeed;
end

function Fight:getFighter(id)
    for i, j in pairs(self.teams) do
        for k, v in pairs(j.fighters) do
            if v.fighterId == id then
                return v;
            end
        end
    end
    return nil;
end
--[[
   * 记录战斗日志
   *
   * @param
   * @param parameters
   */]]
--public void log(String message, Object... parameters) {
--if (!isDebug()) {
--return ;
--}
--
--LogUtil.openLog(this);
--if (getLog() == null) {
--return ;
--}
--
--message = "[{}]" .. message;
--Object[] newParams = new Object[parameters.length + 1];
--newParams[nil] = getFrame();
--System.arraycopy(parameters, nil, newParams, 1, parameters.length);
--
--getLog().info(message, newParams);
--}

--[[
  * 战报保存位置
  * @ return
  */]]
--public String reportSavePath(int serverId) {
--String savePath = nil+ getFightId();
--int reportSaveTypeEnum = getReportSaveTypeEnum();
--ReportSaveTypeEnum saveTypeEnum = ReportSaveTypeEnum.valueOf(reportSaveTypeEnum);
--if (saveTypeEnum != null && !StringUtils.isEmpty(saveTypeEnum.getReportPath())){
--savePath = saveTypeEnum.getReportPath() + getFightId();
--}
--return serverId+"/"+savePath;
--}
--end
--end
function Fight:addFrozenSkills(skill)
    if (skill == nil) then
        return ;
    end
    table.insert(frozenSkills, skill);
end

function Fight:isPVP()
    local fightType = self.fightType;
    if fightType == FightTypeConst.ARENA or fightType == FightTypeConst.DUNGEON_RANDOM_PLAYER_BATTLE or fightType == FightTypeConst.FRIEND_ATTACK or fightType == FightTypeConst.RANK_BATTLE or
            fightType == FightTypeConst.GUILD_BATTLE or fightType == FightTypeConst.DarkStreet then
        return true;
    else
        return false;
    end
end
